<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" />
    <title>用户管理</title>
    <link rel="stylesheet" th:href="@{/css/style.css}" />
</head>
<body>
<div class="container">
    <h1>用户管理</h1>
    <a class="btn" href="/admin">返回管理员控制台</a>
    <table class="table">
        <thead><tr><th>ID</th><th>用户名</th><th>姓名</th><th>电话</th><th>积分</th><th>角色</th><th>操作</th></tr></thead>
        <tbody>
        <tr th:each="u : ${items}">
            <td th:text="${u.id}"></td>
            <td th:text="${u.username}"></td>
            <td th:text="${u.name}"></td>
            <td th:text="${u.phone}"></td>
            <td th:text="${u.points}"></td>
            <td th:text="${u.admin} ? '管理员' : '用户'"></td>
            <td>
                <form th:action="@{'/admin/users/' + ${u.id} + '/delete'}" method="post" style="display:inline"><button class="btn" type="submit">删除</button></form>
                <form th:if="${!u.admin}" th:action="@{'/admin/users/' + ${u.id} + '/grant-admin'}" method="post" style="display:inline"><button class="btn" type="submit">设为管理员</button></form>
                <form th:if="${u.admin}" th:action="@{'/admin/users/' + ${u.id} + '/revoke-admin'}" method="post" style="display:inline"><button class="btn" type="submit">取消管理员</button></form>
            </td>
        </tr>
        </tbody>
    </table>
</div>
</body>
</html>